import request from "@/assets/js/request";
import store from "@/store";
import util from '@/assets/js/public';

export function getDictList(val,isPublic){
    return request({
        url:process.env.VUE_APP_URL+'/sys/dictValue/findDictValue',
        contentType:'application/json;charset=UTF-8',
        data:{
            dictType:val
            //isPublic:(isPublic===undefined || isPublic)?true:false
        }        
    })
}
export function uumsGetDictList(val){
    return request({
        //url:'/uums/sys/dictValue/findDictValue/sso?loginuser='+util.encrypt(store.getters.user.username)+'&appcode='+process.env.VUE_APP_UUMSBASEURL,
        url:process.env.VUE_APP_URL+'/uums/sys/dictvalue/findDictValue',
        contentType:'application/json;charset=UTF-8',
        data:{
            dictType:val
        }        
    })
}
export function testIo(){
    return request({
        url:process.env.VUE_APP_URL+'/anonymous/testIo',
        method:'get',
        responseType: 'blob',
        contentType:'application/json;charset=UTF-8'
    })
}
export function getDictValueForUserType(val){
    return request({
        url:process.env.VUE_APP_URL+'/action/tms/ManagementCostConfig/getDictValueForUserType?isInternalUserForCmcc=false',
        contentType:'application/json;charset=UTF-8',
        data:{
            dictType:val
        }        
    })
}

export function uploadProcessFiles(fd,{fileType,processInstId}){
    // let url=util.toUrl(,data || {});
    
    let url = process.env.VUE_APP_URL+'/sys/file/uploadProcessFiles/api?';
    /**
     * 对比照片 repairPhotoCompare
     * 验收材料 receiptMaterial
     * **/ 
    switch (fileType) {
        case 'repairPhotoCompare':
            url += 'pmInsType=airCondition&pmInsTypePart=1&processInstId='+processInstId
            break;
        case 'receiptMaterial':
            url += 'pmInsType=airCondition&pmInsTypePart=2&processInstId='+processInstId
            break;    
        case 'budgetList':
            url += 'pmInsType=house&pmInsTypePart=3'
            break; 
        default:
            break;
    }
    return request({
        url,
        contentType:'multipart/form-data',
        data:fd,
        catch:true
    })
}

// 删除上传的文件
export function deleteFilesById(id){
    return request({
        url: process.env.VUE_APP_URL+'/action/query/car/deleteFileById/api?id='+id,
    })
}



export function findPOrgAndCityOrg(){
    return request({
        url:process.env.VUE_APP_URL+'/uums/sys/org/findPOrgAndCityOrg?appcode='+process.env.VUE_APP_APPCODE,
    })
}
export function findSonByParentOrgId(orgCode){
    return request({
        url:process.env.VUE_APP_URL+'/uums/sys/org/findSonByParentOrgId?appcode='+process.env.VUE_APP_APPCODE+'&orgCode='+orgCode,        
        contentType:'application/json;charset=UTF-8'
    })
}
export function findOrgTreeFromCorp(val){
    return request({
        url:process.env.VUE_APP_URL+'/uums/sys/org/findOrgTreeFromCorp?appcode='+process.env.VUE_APP_APPCODE,
        contentType:'application/json;charset=UTF-8',
        data:{
            corpId:val
        }        
    })
}
export function findUserOrgDim(params){
    params.appcode=process.env.VUE_APP_APPCODE;
    let url=util.toUrl(process.env.VUE_APP_URL+'/uums/sys/userinfo/findUserOrgDim',params);
    return request({
        url:url,
        //contentType:'application/json;charset=UTF-8',
        //data:params
    })
}

// 查询数据字典
export function queryByType(dictType){
    return request({
        url:process.env.VUE_APP_URL+'/action/queryDictValue/api/queryByType',
        // url:process.env.VUE_APP_URL+'/sys/dictValue/findDictValue/api',
        // async:false,
        // contentType:'application/json;charset=UTF-8',
        data:dictType
    })
}

// 获取决策项
export function getDecisions(params){
    return request({
        url:process.env.VUE_APP_URL+'/action/decisionAndUser/api/getDecisions',
        data:params  
    })
}
// 根据决策项出人或者部门
export function getOrgAndUser(params){
    if (params.applyType == 'sp') {
        var url = process.env.VUE_APP_URL+'/action/applicationForm/api/getOrgAndUser?location=' + params.location + '&source=MOBILE' + '&currentUserCode=' + util.encrypt(params.currentUserCode);
        if(params.processInstId){
            url = process.env.VUE_APP_URL+'/action/applicationForm/api/getOrgAndUser?location=' + params.location + '&source=MOBILE' + '&currentUserCode=' + util.encrypt(params.currentUserCode) + '&processInstId=' + params.processInstId ;
        }
    }
    if (params.applyType == 'gz') {
        var url = process.env.VUE_APP_URL+'/actionGZ/applicationPurchaseForm/api/getOrgAndUser?location=' + params.location + '&source=MOBILE' + '&currentUserCode=' + util.encrypt(params.currentUserCode);
        if(params.processInstId){
            url = process.env.VUE_APP_URL+'/actionGZ/applicationPurchaseForm/api/getOrgAndUser?location=' + params.location + '&source=MOBILE' + '&currentUserCode=' + util.encrypt(params.currentUserCode) + '&processInstId=' + params.processInstId ;
        }
    }
    return request({
        url:process.env.VUE_APP_URL+'/action/decisionAndUser/api/getOrgAndUser?location=' + params.location + '&source=MOBILE' + '&currentUserCode=' + util.encrypt(params.currentUserCode) + '&processInstId=' + params.processInstId ,
        contentType:'application/json;charset=UTF-8',
        data:params.appDecision  
    })
}
// 流程跟踪 
export function findStepListNoPage(params){
    return request({
        url:process.env.VUE_APP_URL+'/flow/step/api/findStepListNoPage?source=' + process.env.VUE_APP_SOURCE,
        contentType:'application/json;charset=UTF-8',
        data:{formId:params}
    })
}
// 阅知 
export function readFlowNotice(params){
    return request({
        url:process.env.VUE_APP_URL+'/flow/notice/api/readFlowNotice?source=' + process.env.VUE_APP_SOURCE + '&id=' + params,
        contentType:'application/json;charset=UTF-8',
        // data:{id:params}
    })
}
